/**
 * 
 */
package com.sci.web.action.datareportseason;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Benefit;
import com.sci.web.dao.DataReportM_BaseInfoDao;

/**
 * @author  BaiFuyou
 * @date: Nov 4, 2011 12:11:07 PM
 * 
 * 增加一条新的数据
 */
public class AddNewBenefitData_BaseInfoAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2562037752814565673L;
	@Resource
	private DataReportM_BaseInfoDao dataReportM_BaseInfoDao;
	
	private int userid;
	/**
	 * 年度
	 */
	private String year;
	/**
	 * 申报类型
	 */
	private int type;
	/**
	 * 主收入
	 */
	private double benefit_major_business_lastyear_sale;
	/**
	 * 利润
	 */
	private double benefit_profit;
	/**
	 * 利税
	 */
	private double benefit_profit_tax;
	/**
	 * @return the userid
	 */
	public int getUserid() {
		return userid;
	}
	/**
	 * @param userid the userid to set
	 */
	public void setUserid(int userid) {
		this.userid = userid;
	}
	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}
	/**
	 * @param year the year to set
	 */
	public void setYear(String year) {
		this.year = year;
	}
	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}
	/**
	 * @return the benefit_major_business_lastyear_sale
	 */
	public double getBenefit_major_business_lastyear_sale() {
		return benefit_major_business_lastyear_sale;
	}
	/**
	 * @param benefit_major_business_lastyear_sale the benefit_major_business_lastyear_sale to set
	 */
	public void setBenefit_major_business_lastyear_sale(double benefit_major_business_lastyear_sale) {
		this.benefit_major_business_lastyear_sale = benefit_major_business_lastyear_sale;
	}
	/**
	 * @return the benefit_profit
	 */
	public double getBenefit_profit() {
		return benefit_profit;
	}
	/**
	 * @param benefit_profit the benefit_profit to set
	 */
	public void setBenefit_profit(double benefit_profit) {
		this.benefit_profit = benefit_profit;
	}
	/**
	 * @return the benefit_profit_tax
	 */
	public double getBenefit_profit_tax() {
		return benefit_profit_tax;
	}
	/**
	 * @param benefit_profit_tax the benefit_profit_tax to set
	 */
	public void setBenefit_profit_tax(double benefit_profit_tax) {
		this.benefit_profit_tax = benefit_profit_tax;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		if(dataReportM_BaseInfoDao.isDataIsExist(userid, year, type)){
			super.outPrint("already");
			return "json";
		}
		Enterprise_Benefit eb = new Enterprise_Benefit();
		eb.setBenefit_check_pass(3);
		eb.setBenefit_id(0);
		eb.setEnterprise_id(dataReportM_BaseInfoDao.getEnterpriseId(userid));
		eb.setBenefit_major_business_lastyear_sale(benefit_major_business_lastyear_sale);
		eb.setBenefit_profit(benefit_profit);
		eb.setBenefit_is_new(0);
		eb.setBenefit_type(type);
		eb.setBenefit_year(year);
		eb.setEditable(1);
		eb.setBenefit_profit_tax(benefit_profit_tax);
		if(dataReportM_BaseInfoDao.isDataIsExist(userid, year, type)){
			super.outPrint("already");
			return "json";
		}
		if(dataReportM_BaseInfoDao.insertNewBenefitData(eb)){
			super.outPrint("ok");
		}else{
			super.outPrint("fail");
		}
		return "json";
	}

}
